package cn.lsh.main;

import cn.lsh.mapper.TempMapper;
import cn.lsh.reducer.TempReducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class TempDriver {

	public static void main(String[] args) throws Exception {
		Configuration conf = new Configuration();
		Job job = new Job(conf, "Temp");

		job.setJarByClass(TempDriver.class);

		job.setMapperClass(TempMapper.class);
		job.setMapOutputKeyClass(Text.class);
		job.setMapOutputValueClass(Text.class);

		job.setReducerClass(TempReducer.class);
		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(Text.class);

		//设置文件的输入路径
		FileInputFormat.addInputPath(job, new Path(args[0]));
		//设置文件的输出路径
		FileOutputFormat.setOutputPath(job, new Path(args[1]));

		//提交任务
		Boolean b = job.waitForCompletion(true);
		if (!b) {
			System.err.println("failed");
		} else {
			System.out.println("finished!");
		}
	}
}
